/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Mark
 * Started 5/16/08
 */
package gamefiles;

import java.awt.Color;
import java.util.ArrayList;

public class StrategoSoldier extends Object implements Comparable
    {
    public StrategoSoldier(Coordinate cd)
        {
        this("Test Soldier", 0, cd, Color.RED);
        //testing with putting a string of only 1's, It seems that the max
        //char count is 9 for written strings on the libs
        }
    public StrategoSoldier(String name, int val, Coordinate coor,
            Color myCol)
        {
        super();
        if (name == null)
            throw new IllegalArgumentException("Null name input");
        if (val < 0 || val > 12)
            //Check these values Joey
            throw new IllegalArgumentException("Value not in bounds");
        this.val = val;
        this.name = name;
        cd = coor;
        numBattles = 0;
        setColor(myCol);
        }
    public int compareTo(Object ob)
        {
        return 0;
        }
    public void setCoordinate(Coordinate a)
        {
        if (a == null)
            throw new IllegalArgumentException("Null Coordinate");
        cd = a;
        }
    public void draw(boolean showName)
        /*
         * if showName is true it will write the name of the soldier
         * else nothing
         */
        {
        Color formerCol = CSAGraphicLib.getPenColor();
        int penW = CSAGraphicLib.getPenWidth();
        // saves the past settings
        CSAGraphicLib.setPenColor(col);
        CSAGraphicLib.setPenWidth(Coordinate.MAX_PEN_WIDTH);
        // inputs the settings to draw the circle
        CSAGraphicLib.fillCircle(cd.getX(), cd.getY(), 
                Coordinate.DEFAULT_RADIUS);
        //draws the Stratego piece
        CSAGraphicLib.setPenColor(Color.BLACK);
        CSAGraphicLib.setPenWidth(Coordinate.MIN_PEN_WIDTH);
        //sets the pen to black and small to drawString
        if (showName)
        CSAGraphicLib.drawString(cd.getX() - Coordinate.DEFAULT_RADIUS
                , cd.getY(), getName());
        //sets the name
        CSAGraphicLib.setPenColor(formerCol);
        CSAGraphicLib.setPenWidth(penW);
        // turns the colors back to what they were before
        }
    public void setColor(Color colo)
        {
        if (col == null && colo == null)
            {
            col = Color.BLACK;
            return;
            }
        if (colo != null)
            col = colo;
        }
    public static ArrayList<StrategoSoldier> 
            getSoldierCompleteSet(boolean local)
        // makes the color blue for local player pieces and red for distant
        // player pieces (network)
        // returns an ArrayList of the complete set of StrategoSoldiers
        {
        Color playerCol = null;
        if (local)
            playerCol = LOCAL_PLAYER_COLOR;
        else
            playerCol = NETWORK_PLAYER_COLOR;
        ArrayList<StrategoSoldier> solds = new ArrayList<StrategoSoldier>(
                DEFAULT_PIECES);
        //Adding Marshal
        solds.add(new StrategoMarshal(MARSHAL, MARSHAL_VAL, null, playerCol));
        //Adding General
        solds.add(new StrategoGeneral(GENERAL, MARSHAL_VAL, null, playerCol));
        //Adding 2 Colonels
        solds.add(new StrategoColonel(COLONEL, COLONEL_VAL, null, playerCol));
        solds.add(new StrategoColonel(COLONEL, COLONEL_VAL, null, playerCol));
        //Adding 3 majors
        for (int i = 0; i < 3; i++)
            solds.add(new StrategoMajor(MAJOR, MAJOR_VAL, null, playerCol));
        //Adding 4 Captains
        for (int i = 0; i < 4; i++)
            solds.add(new StrategoCaptain(CAPTAIN, CAPTAIN_VAL,
                    null, playerCol));
        //Addings 4 Lieutenants
        for (int i = 0; i < 4; i++)
            solds.add(new StrategoLieutenant(LIEUTENANT, LIEUTENANT_VAL,
                    null, playerCol));
        //Adding 4 Sergeants
        for (int i = 0; i < 4; i++)
            solds.add(new StrategoSergeant(SERGEANT, SERGEANT_VAL,
                    null, playerCol));
        //Adding 5 Minors
        for (int i = 0; i < 5; i++)
            solds.add(new StrategoMiner(MINER, MINER_VAL, null, playerCol));
        //Adding 8 Scouts
        for (int i = 0; i < 8; i++)
            solds.add(new StrategoScout(SCOUT, SCOUT_VAL, null, playerCol));
        //Adding a spy
        solds.add(new StrategoSpy(SPY, SPY_VAL, null, playerCol));
        //Adding 6 bombs
        for (int i = 0; i < 6; i++)
            solds.add(new StrategoBomb(BOMB, BOMB_VAL, null, playerCol));
        //Addings 1 flag
        solds.add(new StrategoFlag(FLAG, FLAG_VAL, null, playerCol));
        if (solds.size() == DEFAULT_PIECES)
            return solds;
        else
            throw new IndexOutOfBoundsException("There must be 40 pieces" +
                    "in the default ArrayList");
        }
    public String toString()
        {
        String status = new String();
        status = "Stratego Soldier Status\n";
        status += "I am a " + name + ".\n";
        status += "Piece Value: " + val + "\n";
        status += "Stratego Soldier Coordinate Status:\n";
        status += "" + cd;
        status += "Battles Counter: " + numBattles + "\n";
        status += "Color: " + col + ".\n";
        return status;
        }
    public String getName()
        {
        return name;
        }
    public int getValue()
        {
        return val;
        }
    private String name;
    private int val;
    private Coordinate cd;
    private Color col;
    private int numBattles;
    
    //Constant ints
    public static final int DEFAULT_PIECES = 40;
    
    
    //Constant Soldier Names
    public static final String MARSHAL = "Marshal";
    public static final String GENERAL = "General";
    public static final String COLONEL = "Colonel";
    public static final String MAJOR = "Major";
    public static final String CAPTAIN = "Captain";
    public static final String LIEUTENANT = "Lieutenant";
    public static final String SERGEANT = "Sergeant";
    public static final String SCOUT = "Scount";
    public static final String MINER = "Miner";
    public static final String SPY = "Spy";
    public static final String BOMB = "Bomb";
    public static final String FLAG = "Flag";
    
    // Constant Soldier Values
    //to be constructed by Joey since i dont know the values
    public static final int MARSHAL_VAL = 0;
    public static final int GENERAL_VAL = 0;
    public static final int COLONEL_VAL = 0;
    public static final int MAJOR_VAL = 0;
    public static final int CAPTAIN_VAL = 0;
    public static final int LIEUTENANT_VAL = 0;
    public static final int SERGEANT_VAL = 0;
    public static final int SCOUT_VAL = 0;
    public static final int MINER_VAL = 0;
    public static final int SPY_VAL = 0;
    public static final int BOMB_VAL = 0;
    public static final int FLAG_VAL = 0;
    
    //Constant Soldier Color Values
    public static final Color LOCAL_PLAYER_COLOR = Color.BLUE;
    public static final Color NETWORK_PLAYER_COLOR = Color.RED;
    }

class StrategoMarshal extends StrategoSoldier
    {
    public StrategoMarshal(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoGeneral extends StrategoSoldier
    {
    public StrategoGeneral(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoColonel extends StrategoSoldier
    {
    public StrategoColonel(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoMajor extends StrategoSoldier
    {
    public StrategoMajor(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoCaptain extends StrategoSoldier
    {
    public StrategoCaptain(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoLieutenant extends StrategoSoldier
    {
    public StrategoLieutenant(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoSergeant extends StrategoSoldier
    {
    public StrategoSergeant(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoScout extends StrategoSoldier
    {
    public StrategoScout(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoMiner extends StrategoSoldier
    {
    public StrategoMiner(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoSpy extends StrategoSoldier
    {
    public StrategoSpy(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }
    
class StrategoBomb extends StrategoSoldier
    {
    public StrategoBomb(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }

class StrategoFlag extends StrategoSoldier
    {
    public StrategoFlag(String name, int val, Coordinate coor,
            Color myCol)
        {
        super(name,val, coor, myCol);
        }
    }